package cn.xie.blog.serverutil.exception;

import cn.xie.blog.model.common.enums.response.ResponseCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;

/**
 * @author: xiaoxie
 * create: 2025-04-21 22:03
 * @BelongsProject: blog-parent
 * @BelongsPackage: cn.xie.blog.serverutil.execption
 * description: 全局异常类
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Getter
public class BlogException extends RuntimeException {

    public Integer code;
    public String msg;
    public BlogException(Integer code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BlogException(ResponseCodeEnum responseCodeEnum) {
        super(responseCodeEnum.getMessage());
        this.code = responseCodeEnum.getCode();
        this.msg = responseCodeEnum.getMessage();
    }
    public String getMsg() {
        return msg;
    }
    public Integer getCode() {
        return code;
    }

    @Override
    public String toString() {
        return "GuliException{" +
                "code=" + code +
                ", message=" + this.getMsg() +
                '}';
    }
}
